{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "<!--\n",
    " * @FileDescription: RF trained on phishing.csv dataset\n",
    " * @Author: Zhou Yanjiang（Aaron）\n",
    " * @Date: 2021/9/16\n",
    " * @LastEditors: Zhou Yanjiang（Aaron）\n",
    " -->"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "source": [
    "import pandas as pd\r\n",
    "import numpy as np\r\n",
    "from sklearn.metrics import accuracy_score\r\n",
    "from sklearn.ensemble import RandomForestClassifier\r\n",
    "from sklearn.decomposition import PCA\r\n",
    "from sklearn.model_selection import train_test_split\r\n",
    "from sklearn.model_selection import GridSearchCV"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "source": [
    "data = pd.read_csv('Data/Phishing.csv')\r\n",
    "data"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Querylength</th>\n",
       "      <th>domain_token_count</th>\n",
       "      <th>path_token_count</th>\n",
       "      <th>avgdomaintokenlen</th>\n",
       "      <th>longdomaintokenlen</th>\n",
       "      <th>avgpathtokenlen</th>\n",
       "      <th>tld</th>\n",
       "      <th>charcompvowels</th>\n",
       "      <th>charcompace</th>\n",
       "      <th>ldl_url</th>\n",
       "      <th>...</th>\n",
       "      <th>SymbolCount_FileName</th>\n",
       "      <th>SymbolCount_Extension</th>\n",
       "      <th>SymbolCount_Afterpath</th>\n",
       "      <th>Entropy_URL</th>\n",
       "      <th>Entropy_Domain</th>\n",
       "      <th>Entropy_DirectoryName</th>\n",
       "      <th>Entropy_Filename</th>\n",
       "      <th>Entropy_Extension</th>\n",
       "      <th>Entropy_Afterpath</th>\n",
       "      <th>URL_Type_obf_Type</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>12</td>\n",
       "      <td>5.500000</td>\n",
       "      <td>8</td>\n",
       "      <td>4.083334</td>\n",
       "      <td>2</td>\n",
       "      <td>15</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>0.676804</td>\n",
       "      <td>0.860529</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.00000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>benign</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>12</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>10</td>\n",
       "      <td>3.583333</td>\n",
       "      <td>3</td>\n",
       "      <td>12</td>\n",
       "      <td>8</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>-1</td>\n",
       "      <td>0.715629</td>\n",
       "      <td>0.776796</td>\n",
       "      <td>0.693127</td>\n",
       "      <td>0.738315</td>\n",
       "      <td>1.00000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>benign</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>11</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>5</td>\n",
       "      <td>4.750000</td>\n",
       "      <td>2</td>\n",
       "      <td>16</td>\n",
       "      <td>11</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.677701</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.677704</td>\n",
       "      <td>0.916667</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.898227</td>\n",
       "      <td>benign</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "      <td>4.500000</td>\n",
       "      <td>7</td>\n",
       "      <td>5.714286</td>\n",
       "      <td>2</td>\n",
       "      <td>15</td>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-1</td>\n",
       "      <td>0.696067</td>\n",
       "      <td>0.879588</td>\n",
       "      <td>0.818007</td>\n",
       "      <td>0.753585</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>benign</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>19</td>\n",
       "      <td>2</td>\n",
       "      <td>10</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>9</td>\n",
       "      <td>2.250000</td>\n",
       "      <td>2</td>\n",
       "      <td>9</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>0.747202</td>\n",
       "      <td>0.833700</td>\n",
       "      <td>0.655459</td>\n",
       "      <td>0.829535</td>\n",
       "      <td>0.83615</td>\n",
       "      <td>0.823008</td>\n",
       "      <td>benign</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15362</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>13</td>\n",
       "      <td>3.333333</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-1</td>\n",
       "      <td>0.797046</td>\n",
       "      <td>0.884870</td>\n",
       "      <td>0.750000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>phishing</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15363</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>9.000000</td>\n",
       "      <td>16</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>0.797564</td>\n",
       "      <td>0.813569</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.00000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>phishing</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15364</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>6.666666</td>\n",
       "      <td>10</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-1</td>\n",
       "      <td>0.791104</td>\n",
       "      <td>0.801139</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>phishing</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15365</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>13</td>\n",
       "      <td>3.333333</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-1</td>\n",
       "      <td>0.716580</td>\n",
       "      <td>0.787659</td>\n",
       "      <td>0.871049</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>phishing</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15366</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>9.000000</td>\n",
       "      <td>15</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>-1</td>\n",
       "      <td>0.797564</td>\n",
       "      <td>0.807835</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.00000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>phishing</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>15367 rows × 80 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       Querylength  domain_token_count  path_token_count  avgdomaintokenlen  \\\n",
       "0                0                   2                12           5.500000   \n",
       "1                0                   3                12           5.000000   \n",
       "2                2                   2                11           4.000000   \n",
       "3                0                   2                 7           4.500000   \n",
       "4               19                   2                10           6.000000   \n",
       "...            ...                 ...               ...                ...   \n",
       "15362            0                   2                 3           8.000000   \n",
       "15363            0                   3                 0           9.000000   \n",
       "15364            0                   3                 2           6.666666   \n",
       "15365            0                   2                 3           8.000000   \n",
       "15366            0                   2                 3           9.000000   \n",
       "\n",
       "       longdomaintokenlen  avgpathtokenlen  tld  charcompvowels  charcompace  \\\n",
       "0                       8         4.083334    2              15            7   \n",
       "1                      10         3.583333    3              12            8   \n",
       "2                       5         4.750000    2              16           11   \n",
       "3                       7         5.714286    2              15           10   \n",
       "4                       9         2.250000    2               9            5   \n",
       "...                   ...              ...  ...             ...          ...   \n",
       "15362                  13         3.333333    2               3            2   \n",
       "15363                  16              NaN    3               0            0   \n",
       "15364                  10         3.000000    3               3            2   \n",
       "15365                  13         3.333333    2               4            2   \n",
       "15366                  15         3.000000    2               2            1   \n",
       "\n",
       "       ldl_url  ...  SymbolCount_FileName  SymbolCount_Extension  \\\n",
       "0            0  ...                    -1                     -1   \n",
       "1            2  ...                     1                      0   \n",
       "2            0  ...                     2                      0   \n",
       "3            0  ...                     0                      0   \n",
       "4            0  ...                     5                      4   \n",
       "...        ...  ...                   ...                    ...   \n",
       "15362        0  ...                     0                      0   \n",
       "15363        0  ...                    -1                     -1   \n",
       "15364        0  ...                     0                      0   \n",
       "15365        0  ...                     0                      0   \n",
       "15366        0  ...                     1                      0   \n",
       "\n",
       "       SymbolCount_Afterpath  Entropy_URL  Entropy_Domain  \\\n",
       "0                         -1     0.676804        0.860529   \n",
       "1                         -1     0.715629        0.776796   \n",
       "2                          1     0.677701        1.000000   \n",
       "3                         -1     0.696067        0.879588   \n",
       "4                          3     0.747202        0.833700   \n",
       "...                      ...          ...             ...   \n",
       "15362                     -1     0.797046        0.884870   \n",
       "15363                     -1     0.797564        0.813569   \n",
       "15364                     -1     0.791104        0.801139   \n",
       "15365                     -1     0.716580        0.787659   \n",
       "15366                     -1     0.797564        0.807835   \n",
       "\n",
       "       Entropy_DirectoryName  Entropy_Filename  Entropy_Extension  \\\n",
       "0                  -1.000000         -1.000000           -1.00000   \n",
       "1                   0.693127          0.738315            1.00000   \n",
       "2                   0.677704          0.916667            0.00000   \n",
       "3                   0.818007          0.753585            0.00000   \n",
       "4                   0.655459          0.829535            0.83615   \n",
       "...                      ...               ...                ...   \n",
       "15362               0.750000          1.000000            0.00000   \n",
       "15363              -1.000000         -1.000000           -1.00000   \n",
       "15364                    NaN          1.000000            0.00000   \n",
       "15365               0.871049          1.000000            0.00000   \n",
       "15366                    NaN          1.000000            1.00000   \n",
       "\n",
       "       Entropy_Afterpath  URL_Type_obf_Type  \n",
       "0              -1.000000             benign  \n",
       "1              -1.000000             benign  \n",
       "2               0.898227             benign  \n",
       "3              -1.000000             benign  \n",
       "4               0.823008             benign  \n",
       "...                  ...                ...  \n",
       "15362          -1.000000           phishing  \n",
       "15363          -1.000000           phishing  \n",
       "15364          -1.000000           phishing  \n",
       "15365          -1.000000           phishing  \n",
       "15366          -1.000000           phishing  \n",
       "\n",
       "[15367 rows x 80 columns]"
      ]
     },
     "metadata": {},
     "execution_count": 2
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "source": [
    "data.columns"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "Index(['Querylength', 'domain_token_count', 'path_token_count',\n",
       "       'avgdomaintokenlen', 'longdomaintokenlen', 'avgpathtokenlen', 'tld',\n",
       "       'charcompvowels', 'charcompace', 'ldl_url', 'ldl_domain', 'ldl_path',\n",
       "       'ldl_filename', 'ldl_getArg', 'dld_url', 'dld_domain', 'dld_path',\n",
       "       'dld_filename', 'dld_getArg', 'urlLen', 'domainlength', 'pathLength',\n",
       "       'subDirLen', 'fileNameLen', 'this.fileExtLen', 'ArgLen', 'pathurlRatio',\n",
       "       'ArgUrlRatio', 'argDomanRatio', 'domainUrlRatio', 'pathDomainRatio',\n",
       "       'argPathRatio', 'executable', 'isPortEighty', 'NumberofDotsinURL',\n",
       "       'ISIpAddressInDomainName', 'CharacterContinuityRate',\n",
       "       'LongestVariableValue', 'URL_DigitCount', 'host_DigitCount',\n",
       "       'Directory_DigitCount', 'File_name_DigitCount', 'Extension_DigitCount',\n",
       "       'Query_DigitCount', 'URL_Letter_Count', 'host_letter_count',\n",
       "       'Directory_LetterCount', 'Filename_LetterCount',\n",
       "       'Extension_LetterCount', 'Query_LetterCount', 'LongestPathTokenLength',\n",
       "       'Domain_LongestWordLength', 'Path_LongestWordLength',\n",
       "       'sub-Directory_LongestWordLength', 'Arguments_LongestWordLength',\n",
       "       'URL_sensitiveWord', 'URLQueries_variable', 'spcharUrl',\n",
       "       'delimeter_Domain', 'delimeter_path', 'delimeter_Count',\n",
       "       'NumberRate_URL', 'NumberRate_Domain', 'NumberRate_DirectoryName',\n",
       "       'NumberRate_FileName', 'NumberRate_Extension', 'NumberRate_AfterPath',\n",
       "       'SymbolCount_URL', 'SymbolCount_Domain', 'SymbolCount_Directoryname',\n",
       "       'SymbolCount_FileName', 'SymbolCount_Extension',\n",
       "       'SymbolCount_Afterpath', 'Entropy_URL', 'Entropy_Domain',\n",
       "       'Entropy_DirectoryName', 'Entropy_Filename', 'Entropy_Extension',\n",
       "       'Entropy_Afterpath', 'URL_Type_obf_Type'],\n",
       "      dtype='object')"
      ]
     },
     "metadata": {},
     "execution_count": 3
    }
   ],
   "metadata": {
    "scrolled": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "source": [
    "data = data.dropna(axis = 0)\r\n",
    "y = data.pop('URL_Type_obf_Type')\r\n",
    "X = data"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "source": [
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1234)\r\n",
    "X_train\r\n"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Querylength</th>\n",
       "      <th>domain_token_count</th>\n",
       "      <th>path_token_count</th>\n",
       "      <th>avgdomaintokenlen</th>\n",
       "      <th>longdomaintokenlen</th>\n",
       "      <th>avgpathtokenlen</th>\n",
       "      <th>tld</th>\n",
       "      <th>charcompvowels</th>\n",
       "      <th>charcompace</th>\n",
       "      <th>ldl_url</th>\n",
       "      <th>...</th>\n",
       "      <th>SymbolCount_Directoryname</th>\n",
       "      <th>SymbolCount_FileName</th>\n",
       "      <th>SymbolCount_Extension</th>\n",
       "      <th>SymbolCount_Afterpath</th>\n",
       "      <th>Entropy_URL</th>\n",
       "      <th>Entropy_Domain</th>\n",
       "      <th>Entropy_DirectoryName</th>\n",
       "      <th>Entropy_Filename</th>\n",
       "      <th>Entropy_Extension</th>\n",
       "      <th>Entropy_Afterpath</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>14624</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>9</td>\n",
       "      <td>4.250000</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>-1</td>\n",
       "      <td>0.816235</td>\n",
       "      <td>0.916850</td>\n",
       "      <td>0.871049</td>\n",
       "      <td>0.962479</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5113</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>13</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>6</td>\n",
       "      <td>4.307692</td>\n",
       "      <td>2</td>\n",
       "      <td>14</td>\n",
       "      <td>8</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>-1</td>\n",
       "      <td>0.697210</td>\n",
       "      <td>0.929897</td>\n",
       "      <td>0.871049</td>\n",
       "      <td>0.711838</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12356</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>7</td>\n",
       "      <td>3.666667</td>\n",
       "      <td>7</td>\n",
       "      <td>3.400000</td>\n",
       "      <td>3</td>\n",
       "      <td>9</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0.787853</td>\n",
       "      <td>0.833700</td>\n",
       "      <td>0.842981</td>\n",
       "      <td>0.861719</td>\n",
       "      <td>0.897617</td>\n",
       "      <td>0.894886</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6922</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>7</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>7</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>-1</td>\n",
       "      <td>0.766840</td>\n",
       "      <td>0.887436</td>\n",
       "      <td>0.890135</td>\n",
       "      <td>0.833333</td>\n",
       "      <td>0.827729</td>\n",
       "      <td>-1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14679</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>9</td>\n",
       "      <td>4.250000</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>-1</td>\n",
       "      <td>0.793898</td>\n",
       "      <td>0.916850</td>\n",
       "      <td>0.871049</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1848</th>\n",
       "      <td>13</td>\n",
       "      <td>2</td>\n",
       "      <td>13</td>\n",
       "      <td>4.500000</td>\n",
       "      <td>6</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>2</td>\n",
       "      <td>23</td>\n",
       "      <td>17</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>14</td>\n",
       "      <td>13</td>\n",
       "      <td>12</td>\n",
       "      <td>0.676591</td>\n",
       "      <td>0.796658</td>\n",
       "      <td>0.871049</td>\n",
       "      <td>0.692652</td>\n",
       "      <td>0.699647</td>\n",
       "      <td>0.695870</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8927</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>10</td>\n",
       "      <td>6.666666</td>\n",
       "      <td>14</td>\n",
       "      <td>6.500000</td>\n",
       "      <td>3</td>\n",
       "      <td>12</td>\n",
       "      <td>8</td>\n",
       "      <td>9</td>\n",
       "      <td>...</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>-1</td>\n",
       "      <td>0.736373</td>\n",
       "      <td>0.808833</td>\n",
       "      <td>0.757206</td>\n",
       "      <td>0.877406</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3781</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>11</td>\n",
       "      <td>4.500000</td>\n",
       "      <td>7</td>\n",
       "      <td>3.727273</td>\n",
       "      <td>2</td>\n",
       "      <td>9</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>-1</td>\n",
       "      <td>0.769878</td>\n",
       "      <td>0.939794</td>\n",
       "      <td>0.780753</td>\n",
       "      <td>0.866875</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2031</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>8</td>\n",
       "      <td>5.500000</td>\n",
       "      <td>9</td>\n",
       "      <td>4.375000</td>\n",
       "      <td>2</td>\n",
       "      <td>11</td>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>-1</td>\n",
       "      <td>0.776924</td>\n",
       "      <td>0.860529</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7983</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>7</td>\n",
       "      <td>7.833334</td>\n",
       "      <td>2</td>\n",
       "      <td>23</td>\n",
       "      <td>36</td>\n",
       "      <td>41</td>\n",
       "      <td>...</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.583873</td>\n",
       "      <td>0.789771</td>\n",
       "      <td>0.750290</td>\n",
       "      <td>0.582609</td>\n",
       "      <td>0.570740</td>\n",
       "      <td>0.549769</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5378 rows × 79 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       Querylength  domain_token_count  path_token_count  avgdomaintokenlen  \\\n",
       "14624            0                   2                 4           6.000000   \n",
       "5113             0                   2                13           4.000000   \n",
       "12356            3                   3                 7           3.666667   \n",
       "6922             0                   3                 7           4.000000   \n",
       "14679            0                   2                 4           6.000000   \n",
       "...            ...                 ...               ...                ...   \n",
       "1848            13                   2                13           4.500000   \n",
       "8927             0                   3                10           6.666666   \n",
       "3781             0                   2                11           4.500000   \n",
       "2031             0                   2                 8           5.500000   \n",
       "7983             0                   2                 7           5.000000   \n",
       "\n",
       "       longdomaintokenlen  avgpathtokenlen  tld  charcompvowels  charcompace  \\\n",
       "14624                   9         4.250000    2               2            1   \n",
       "5113                    6         4.307692    2              14            8   \n",
       "12356                   7         3.400000    3               9            6   \n",
       "6922                    7         4.000000    3               5            4   \n",
       "14679                   9         4.250000    2               4            1   \n",
       "...                   ...              ...  ...             ...          ...   \n",
       "1848                    6         3.000000    2              23           17   \n",
       "8927                   14         6.500000    3              12            8   \n",
       "3781                    7         3.727273    2               9            5   \n",
       "2031                    9         4.375000    2              11            8   \n",
       "7983                    7         7.833334    2              23           36   \n",
       "\n",
       "       ldl_url  ...  SymbolCount_Directoryname  SymbolCount_FileName  \\\n",
       "14624        2  ...                          1                     1   \n",
       "5113         1  ...                          1                     1   \n",
       "12356        0  ...                          2                     3   \n",
       "6922         1  ...                          2                     1   \n",
       "14679        1  ...                          1                     1   \n",
       "...        ...  ...                        ...                   ...   \n",
       "1848         0  ...                          1                    14   \n",
       "8927         9  ...                          3                     1   \n",
       "3781         0  ...                          3                     1   \n",
       "2031         0  ...                         -1                    -1   \n",
       "7983        41  ...                          3                     2   \n",
       "\n",
       "       SymbolCount_Extension  SymbolCount_Afterpath  Entropy_URL  \\\n",
       "14624                      0                     -1     0.816235   \n",
       "5113                       0                     -1     0.697210   \n",
       "12356                      2                      1     0.787853   \n",
       "6922                       0                     -1     0.766840   \n",
       "14679                      0                     -1     0.793898   \n",
       "...                      ...                    ...          ...   \n",
       "1848                      13                     12     0.676591   \n",
       "8927                       0                     -1     0.736373   \n",
       "3781                       0                     -1     0.769878   \n",
       "2031                      -1                     -1     0.776924   \n",
       "7983                       1                      0     0.583873   \n",
       "\n",
       "       Entropy_Domain  Entropy_DirectoryName  Entropy_Filename  \\\n",
       "14624        0.916850               0.871049          0.962479   \n",
       "5113         0.929897               0.871049          0.711838   \n",
       "12356        0.833700               0.842981          0.861719   \n",
       "6922         0.887436               0.890135          0.833333   \n",
       "14679        0.916850               0.871049          1.000000   \n",
       "...               ...                    ...               ...   \n",
       "1848         0.796658               0.871049          0.692652   \n",
       "8927         0.808833               0.757206          0.877406   \n",
       "3781         0.939794               0.780753          0.866875   \n",
       "2031         0.860529              -1.000000         -1.000000   \n",
       "7983         0.789771               0.750290          0.582609   \n",
       "\n",
       "       Entropy_Extension  Entropy_Afterpath  \n",
       "14624           1.000000          -1.000000  \n",
       "5113            1.000000          -1.000000  \n",
       "12356           0.897617           0.894886  \n",
       "6922            0.827729          -1.000000  \n",
       "14679           1.000000          -1.000000  \n",
       "...                  ...                ...  \n",
       "1848            0.699647           0.695870  \n",
       "8927            1.000000          -1.000000  \n",
       "3781            1.000000          -1.000000  \n",
       "2031           -1.000000          -1.000000  \n",
       "7983            0.570740           0.549769  \n",
       "\n",
       "[5378 rows x 79 columns]"
      ]
     },
     "metadata": {},
     "execution_count": 5
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "source": [
    "clf = RandomForestClassifier(n_estimators=80, max_depth=85)\n",
    "clf.fit(X_train, y_train)"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "RandomForestClassifier(max_depth=85, n_estimators=80)"
      ]
     },
     "metadata": {},
     "execution_count": 6
    }
   ],
   "metadata": {
    "scrolled": true
   }
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "source": [
    "k = 5\n",
    "n_estimators_range = np.arange(80,90,1)\n",
    "max_depth_range = np.arange(80,90,1)\n",
    "params = {\n",
    "    'max_depth': max_depth_range,\n",
    "    'n_estimators': n_estimators_range\n",
    "}\n",
    "\n",
    "grid_model = GridSearchCV(estimator=clf,\n",
    "                          param_grid=params,\n",
    "                          cv=k,\n",
    "                          return_train_score=True,\n",
    "                          scoring='accuracy'                        )\n",
    "\n",
    "grid_model_result = grid_model.fit(X_train, y_train)\n"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "source": [
    "cv_results = pd.DataFrame(grid_model.cv_results_)\n",
    "cv_results.head(10)"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>mean_fit_time</th>\n",
       "      <th>std_fit_time</th>\n",
       "      <th>mean_score_time</th>\n",
       "      <th>std_score_time</th>\n",
       "      <th>param_max_depth</th>\n",
       "      <th>param_n_estimators</th>\n",
       "      <th>params</th>\n",
       "      <th>split0_test_score</th>\n",
       "      <th>split1_test_score</th>\n",
       "      <th>split2_test_score</th>\n",
       "      <th>...</th>\n",
       "      <th>mean_test_score</th>\n",
       "      <th>std_test_score</th>\n",
       "      <th>rank_test_score</th>\n",
       "      <th>split0_train_score</th>\n",
       "      <th>split1_train_score</th>\n",
       "      <th>split2_train_score</th>\n",
       "      <th>split3_train_score</th>\n",
       "      <th>split4_train_score</th>\n",
       "      <th>mean_train_score</th>\n",
       "      <th>std_train_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.726529</td>\n",
       "      <td>0.027570</td>\n",
       "      <td>0.027343</td>\n",
       "      <td>0.002179</td>\n",
       "      <td>80</td>\n",
       "      <td>80</td>\n",
       "      <td>{'max_depth': 80, 'n_estimators': 80}</td>\n",
       "      <td>0.978625</td>\n",
       "      <td>0.978625</td>\n",
       "      <td>0.974907</td>\n",
       "      <td>...</td>\n",
       "      <td>0.976571</td>\n",
       "      <td>0.003648</td>\n",
       "      <td>26</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.758060</td>\n",
       "      <td>0.038448</td>\n",
       "      <td>0.025619</td>\n",
       "      <td>0.001991</td>\n",
       "      <td>80</td>\n",
       "      <td>81</td>\n",
       "      <td>{'max_depth': 80, 'n_estimators': 81}</td>\n",
       "      <td>0.975836</td>\n",
       "      <td>0.973978</td>\n",
       "      <td>0.978625</td>\n",
       "      <td>...</td>\n",
       "      <td>0.976757</td>\n",
       "      <td>0.003377</td>\n",
       "      <td>15</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.685908</td>\n",
       "      <td>0.054098</td>\n",
       "      <td>0.023284</td>\n",
       "      <td>0.001717</td>\n",
       "      <td>80</td>\n",
       "      <td>82</td>\n",
       "      <td>{'max_depth': 80, 'n_estimators': 82}</td>\n",
       "      <td>0.973978</td>\n",
       "      <td>0.975836</td>\n",
       "      <td>0.975836</td>\n",
       "      <td>...</td>\n",
       "      <td>0.975456</td>\n",
       "      <td>0.003607</td>\n",
       "      <td>71</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.999768</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.999954</td>\n",
       "      <td>0.000093</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.858122</td>\n",
       "      <td>0.056040</td>\n",
       "      <td>0.031909</td>\n",
       "      <td>0.008233</td>\n",
       "      <td>80</td>\n",
       "      <td>83</td>\n",
       "      <td>{'max_depth': 80, 'n_estimators': 83}</td>\n",
       "      <td>0.973978</td>\n",
       "      <td>0.972119</td>\n",
       "      <td>0.975836</td>\n",
       "      <td>...</td>\n",
       "      <td>0.975270</td>\n",
       "      <td>0.001994</td>\n",
       "      <td>76</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.770892</td>\n",
       "      <td>0.041599</td>\n",
       "      <td>0.028516</td>\n",
       "      <td>0.006140</td>\n",
       "      <td>80</td>\n",
       "      <td>84</td>\n",
       "      <td>{'max_depth': 80, 'n_estimators': 84}</td>\n",
       "      <td>0.973978</td>\n",
       "      <td>0.975836</td>\n",
       "      <td>0.976766</td>\n",
       "      <td>...</td>\n",
       "      <td>0.975828</td>\n",
       "      <td>0.002276</td>\n",
       "      <td>55</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.904881</td>\n",
       "      <td>0.049405</td>\n",
       "      <td>0.033111</td>\n",
       "      <td>0.004343</td>\n",
       "      <td>80</td>\n",
       "      <td>85</td>\n",
       "      <td>{'max_depth': 80, 'n_estimators': 85}</td>\n",
       "      <td>0.973048</td>\n",
       "      <td>0.978625</td>\n",
       "      <td>0.976766</td>\n",
       "      <td>...</td>\n",
       "      <td>0.975641</td>\n",
       "      <td>0.003501</td>\n",
       "      <td>66</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.987347</td>\n",
       "      <td>0.063157</td>\n",
       "      <td>0.035904</td>\n",
       "      <td>0.001411</td>\n",
       "      <td>80</td>\n",
       "      <td>86</td>\n",
       "      <td>{'max_depth': 80, 'n_estimators': 86}</td>\n",
       "      <td>0.977695</td>\n",
       "      <td>0.974907</td>\n",
       "      <td>0.975836</td>\n",
       "      <td>...</td>\n",
       "      <td>0.976757</td>\n",
       "      <td>0.002117</td>\n",
       "      <td>15</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1.044130</td>\n",
       "      <td>0.119479</td>\n",
       "      <td>0.037903</td>\n",
       "      <td>0.007696</td>\n",
       "      <td>80</td>\n",
       "      <td>87</td>\n",
       "      <td>{'max_depth': 80, 'n_estimators': 87}</td>\n",
       "      <td>0.974907</td>\n",
       "      <td>0.975836</td>\n",
       "      <td>0.977695</td>\n",
       "      <td>...</td>\n",
       "      <td>0.977130</td>\n",
       "      <td>0.001502</td>\n",
       "      <td>10</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.881630</td>\n",
       "      <td>0.023286</td>\n",
       "      <td>0.031716</td>\n",
       "      <td>0.002706</td>\n",
       "      <td>80</td>\n",
       "      <td>88</td>\n",
       "      <td>{'max_depth': 80, 'n_estimators': 88}</td>\n",
       "      <td>0.974907</td>\n",
       "      <td>0.977695</td>\n",
       "      <td>0.973978</td>\n",
       "      <td>...</td>\n",
       "      <td>0.975269</td>\n",
       "      <td>0.003202</td>\n",
       "      <td>77</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.949925</td>\n",
       "      <td>0.032104</td>\n",
       "      <td>0.032021</td>\n",
       "      <td>0.002496</td>\n",
       "      <td>80</td>\n",
       "      <td>89</td>\n",
       "      <td>{'max_depth': 80, 'n_estimators': 89}</td>\n",
       "      <td>0.976766</td>\n",
       "      <td>0.976766</td>\n",
       "      <td>0.977695</td>\n",
       "      <td>...</td>\n",
       "      <td>0.975641</td>\n",
       "      <td>0.001996</td>\n",
       "      <td>69</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 22 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   mean_fit_time  std_fit_time  mean_score_time  std_score_time  \\\n",
       "0       0.726529      0.027570         0.027343        0.002179   \n",
       "1       0.758060      0.038448         0.025619        0.001991   \n",
       "2       0.685908      0.054098         0.023284        0.001717   \n",
       "3       0.858122      0.056040         0.031909        0.008233   \n",
       "4       0.770892      0.041599         0.028516        0.006140   \n",
       "5       0.904881      0.049405         0.033111        0.004343   \n",
       "6       0.987347      0.063157         0.035904        0.001411   \n",
       "7       1.044130      0.119479         0.037903        0.007696   \n",
       "8       0.881630      0.023286         0.031716        0.002706   \n",
       "9       0.949925      0.032104         0.032021        0.002496   \n",
       "\n",
       "  param_max_depth param_n_estimators                                 params  \\\n",
       "0              80                 80  {'max_depth': 80, 'n_estimators': 80}   \n",
       "1              80                 81  {'max_depth': 80, 'n_estimators': 81}   \n",
       "2              80                 82  {'max_depth': 80, 'n_estimators': 82}   \n",
       "3              80                 83  {'max_depth': 80, 'n_estimators': 83}   \n",
       "4              80                 84  {'max_depth': 80, 'n_estimators': 84}   \n",
       "5              80                 85  {'max_depth': 80, 'n_estimators': 85}   \n",
       "6              80                 86  {'max_depth': 80, 'n_estimators': 86}   \n",
       "7              80                 87  {'max_depth': 80, 'n_estimators': 87}   \n",
       "8              80                 88  {'max_depth': 80, 'n_estimators': 88}   \n",
       "9              80                 89  {'max_depth': 80, 'n_estimators': 89}   \n",
       "\n",
       "   split0_test_score  split1_test_score  split2_test_score  ...  \\\n",
       "0           0.978625           0.978625           0.974907  ...   \n",
       "1           0.975836           0.973978           0.978625  ...   \n",
       "2           0.973978           0.975836           0.975836  ...   \n",
       "3           0.973978           0.972119           0.975836  ...   \n",
       "4           0.973978           0.975836           0.976766  ...   \n",
       "5           0.973048           0.978625           0.976766  ...   \n",
       "6           0.977695           0.974907           0.975836  ...   \n",
       "7           0.974907           0.975836           0.977695  ...   \n",
       "8           0.974907           0.977695           0.973978  ...   \n",
       "9           0.976766           0.976766           0.977695  ...   \n",
       "\n",
       "   mean_test_score  std_test_score  rank_test_score  split0_train_score  \\\n",
       "0         0.976571        0.003648               26                 1.0   \n",
       "1         0.976757        0.003377               15                 1.0   \n",
       "2         0.975456        0.003607               71                 1.0   \n",
       "3         0.975270        0.001994               76                 1.0   \n",
       "4         0.975828        0.002276               55                 1.0   \n",
       "5         0.975641        0.003501               66                 1.0   \n",
       "6         0.976757        0.002117               15                 1.0   \n",
       "7         0.977130        0.001502               10                 1.0   \n",
       "8         0.975269        0.003202               77                 1.0   \n",
       "9         0.975641        0.001996               69                 1.0   \n",
       "\n",
       "   split1_train_score  split2_train_score  split3_train_score  \\\n",
       "0                 1.0            1.000000                 1.0   \n",
       "1                 1.0            1.000000                 1.0   \n",
       "2                 1.0            0.999768                 1.0   \n",
       "3                 1.0            1.000000                 1.0   \n",
       "4                 1.0            1.000000                 1.0   \n",
       "5                 1.0            1.000000                 1.0   \n",
       "6                 1.0            1.000000                 1.0   \n",
       "7                 1.0            1.000000                 1.0   \n",
       "8                 1.0            1.000000                 1.0   \n",
       "9                 1.0            1.000000                 1.0   \n",
       "\n",
       "   split4_train_score  mean_train_score  std_train_score  \n",
       "0                 1.0          1.000000         0.000000  \n",
       "1                 1.0          1.000000         0.000000  \n",
       "2                 1.0          0.999954         0.000093  \n",
       "3                 1.0          1.000000         0.000000  \n",
       "4                 1.0          1.000000         0.000000  \n",
       "5                 1.0          1.000000         0.000000  \n",
       "6                 1.0          1.000000         0.000000  \n",
       "7                 1.0          1.000000         0.000000  \n",
       "8                 1.0          1.000000         0.000000  \n",
       "9                 1.0          1.000000         0.000000  \n",
       "\n",
       "[10 rows x 22 columns]"
      ]
     },
     "metadata": {},
     "execution_count": 13
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "source": [
    "cv_results.mean()"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "mean_fit_time          0.907736\n",
       "std_fit_time           0.042300\n",
       "mean_score_time        0.032773\n",
       "std_score_time         0.003728\n",
       "param_max_depth       84.500000\n",
       "param_n_estimators    84.500000\n",
       "split0_test_score      0.975381\n",
       "split1_test_score      0.975697\n",
       "split2_test_score      0.976636\n",
       "split3_test_score      0.978800\n",
       "split4_test_score      0.973367\n",
       "mean_test_score        0.975976\n",
       "std_test_score         0.002239\n",
       "rank_test_score       50.260000\n",
       "split0_train_score     0.999993\n",
       "split1_train_score     0.999993\n",
       "split2_train_score     0.999991\n",
       "split3_train_score     1.000000\n",
       "split4_train_score     0.999995\n",
       "mean_train_score       0.999994\n",
       "std_train_score        0.000011\n",
       "dtype: float64"
      ]
     },
     "metadata": {},
     "execution_count": 12
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "20bebc860e821dfc8c3402aa900049950a23cadb8eca4814f2eb319ccf2768b5"
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}